# import subprocess

# exe_path = "E:\HK_PIN_OUT_V1.0.0.0\exe_out\HK PIN OUT_V1.0.0.0_setup.exe"
# project_path = "E:\HK_PIN_OUT"

# subprocess.run([exe_path, "/S", f"INSTALLDIR={project_path}"], check=True)

#进程池Pool

# import os,time
# from multiprocessing import Pool

# def worker(arg):
#   print("子进程程序开始>>> pid={},ppid={},编号{}".format(os.getpid(),os.getppid(),arg))
#   time.sleep(0.5)
#   print("子进程程序终止>>> pid={},ppid={},编号{}".format(os.getpid(),os.getppid(),arg))
  
# def main():
#   print("主进程开始执行>>> pid={}".format(os.getpid()))
#   ps=Pool(5)
#   for i in range(10):
#     # ps.apply(worker,args=(i,))     # 同步执行
#     ps.apply_async(worker,args=(i,)) # 异步执行
#   # 关闭进程池，停止接受其它进程
#   ps.close()
#   # 阻塞进程
#   ps.join()
#   print("主进程终止")
  
# if __name__ == '__main__':
#   main()

# import time
# import datetime

# # 将时间戳转换为datetime对象
# timestamp = time.time()
# dt = datetime.datetime.fromtimestamp(timestamp)
# print(dt)

# # 将datetime对象转换为时间戳
# timestamp = dt.timestamp()
# print(timestamp)

# # 将datetime对象转换为字符串
# dt = datetime.datetime.now()
# str_dt = dt.strftime('%Y-%m-%d %H:%M:%S')
# print(str_dt)
# # 将字符串转换为datetime对象
# str_dt = '2022-01-01 12:00:00'
# dt = datetime.datetime.strptime(str_dt, '%Y-%m-%d %H:%M:%S')
# print(dt)

# aa=time.time()
# time.sleep(2)
# bb=time.time()
# print(round(bb-aa,3))

# date1 = time.strptime('2023-02-23 14:40:18',"%Y-%m-%d %H:%M:%S")
# date1 = datetime.datetime.strptime('2023-02-23 14:40:18', "%Y-%m-%d %H:%M:%S")
# # date2 = time.strptime('2023-03-02 14:40:18',"%Y-%m-%d %H:%M:%S")
# date2 = datetime.datetime.strptime('2023-03-02 14:40:20',"%Y-%m-%d %H:%M:%S")
# duration = date2-date1
# print(duration.seconds/3600)

# from docx import Document
# from docx.enum.table import WD_TABLE_ALIGNMENT,WD_CELL_VERTICAL_ALIGNMENT
# from docx.enum.section import WD_ORIENTATION
# # from docx.enum.text import WD_CELL_VERTICAL_ALIGNMENT
# from docx.shared import Cm
# import re


# # def get_text_direction(cell):    
# #     # direction: tbRl -- top to bottom, btLr -- bottom to top
# #     pattern = re.compile('w:textDirection w:val=\"(\S*)\"')
# #     match = pattern.search(cell._tc.xml)
# #     if match:
# #         txt = match.group(1)
# #         if txt == 'btLr':
# #             return 90
# #         elif txt == 'tbRl':
# #             return -90
# #     return 0

# # 创建一个新的word文档
# document = Document()
# # 添加一个表格
# table = document.add_table(rows=3, cols=3)
# # 设置表格样式
# table.style = 'Table Grid'
# # 设置表头文字旋转90度竖向排列
# for cell in table.rows[0].cells:
#     # aa=get_text_direction(cell)
#     # print(aa)
#     cell.width = Cm(1.5)
#     cell.heigth = Cm(12)
#     cell.paragraphs[0].alignment = WD_TABLE_ALIGNMENT.CENTER
#     cell.paragraphs[0].text = '表头123'
#     cell.paragraphs[0].orientation = 'btLr'

# # 添加数据到表格中
# for i in range(1, 3):
#     for j in range(3):
#         cell = table.cell(i, j)
#         cell.text = f'第{i}行第{j+1}列'
# # 保存文档
# document.save('table.docx')

# import io
# import base64
# import vsdx
# from svglib.svglib import svg2rlg

# def svg_to_vsd():
#     """"""
#     # 将SVG二进制流转换为字符串
#     svg_binary = b'<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1667874405645" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="17625" width="48" height="48" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M893.44 339.456c-1.472-6.08-3.968-11.968-8.768-16.704L635.008 73.088C626.432 64.512 614.656 61.952 603.648 64L192 64C121.344 64 64 121.344 64 192l0 704c0 70.656 57.344 128 128 128l576 0c70.656 0 128-57.344 128-128L896 352C896 347.52 895.04 343.296 893.44 339.456zM640 177.92 782.08 320 640 320 640 177.92zM832 896c0 35.392-28.608 64-64 64L192 960c-35.392 0-64-28.608-64-64L128 192c0-35.392 28.608-64 64-64l384 0 0 224C576 369.664 590.336 384 608 384L832 384 832 896zM512 416C512 398.336 497.664 384 480 384S448 398.336 448 416L448 576 288 576C270.336 576 256 590.336 256 608S270.336 640 288 640L448 640l0 160C448 817.664 462.336 832 480 832S512 817.664 512 800L512 640l160 0c17.664 0 32-14.336 32-32S689.664 576 672 576L512 576 512 416z" p-id="17626" fill="#1b6b7d"></path></svg>'  # 用实际的SVG二进制流替换这里的省略号
#     svg_string = base64.b64encode(svg_binary).decode('utf-8')

#     # 创建Visio对象
#     # visio = VisioFile()
#     visio = Visio()
#     # 打开SVG文件
#     # 将SVG转换为VSX格式
#     vsx_data = visio.svg_to_vdx(svg_string)
#     # 将VSX保存为文件
#     with open('example.vdx', 'wb') as f:
#         f.write(vsx_data)

# svg_to_vsd()



# subprocess.Popen([r'C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe',
#                                   '.\\SVDConv.exe .\\Files\\SVD\\%s --generate=sfr >>log.txt' % svd_name],
#                                  cwd=keil_basic_pack_path)
# import subprocess
# # 定义输入和输出文件路径
# input_file = "example.svg"
# output_file = "output.vsd"

# # 定义Visio的命令行参数
# visio_exe = "C:\\Program Files (x86)\\office\\Viso.exe"
# # visio_args = "/nologo /convertto vsd " + input_file + " " + output_file

# # 调用Visio进行转换
# # subprocess.Popen([visio_exe, visio_args])
# subprocess.call("{} {} -T -o {}".format(visio_exe, input_file, output_file), shell=True)


import win32com.client

visio = win32com.client.Dispatch("Visio.Application")
doc = visio.Documents.Open("example.svg")
doc.ExportAsFixedFormat(win32com.client.constants.visFixedFormatTypePDF, "example.vsd")
doc.Close()
visio.Quit()
